package com.inei.cie.capitulovi;

import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.opengl.Visibility;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.Spinner;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import android.widget.Toast;
import com.inei.cie.Carga_Trabajo_Activity;
import com.inei.cie.R;
import com.inei.cie.capituloix.CapituloIX_Activity;
import com.inei.cie.dao.CapituloVIDao;
import com.inei.cie.entidades.P6_1;
import com.inei.cie.entidades.P6_1_10N;
import com.inei.cie.entidades.P6_1_8N;
import com.inei.cie.entidades.P6_2;
import com.inei.cie.entidades.P6_2_4N;

public class CapituloVI_SeccionB_Ambiente_Activity extends Activity {

	public TableLayout tlModalidades;
	public TableRow tr6B3, tr6B4, tr6B41, tr6B42, tr6B43, tr6B44, tr6B45,
			tr6B46, tr6B47, tr6B48, tr6B49, tr6B410, tr6B411, tr6B412, tr6B413,
			tr6B414;
	public TextView tvEdificacionNro;
	public TextView tvEdificacion;
	public CheckBox cb6B41, cb6B41M, cb6B41T, cb6B41N, cb6B42, cb6B42M,
			cb6B42T, cb6B42N, cb6B43, cb6B43M, cb6B43T, cb6B43N, cb6B44,
			cb6B44M, cb6B44T, cb6B44N, cb6B45, cb6B45M, cb6B45T, cb6B45N,
			cb6B46, cb6B46M, cb6B46T, cb6B46N, cb6B47, cb6B47M, cb6B47T,
			cb6B47N, cb6B48, cb6B48M, cb6B48T, cb6B48N, cb6B49, cb6B49M,
			cb6B49T, cb6B49N, cb6B410, cb6B410M, cb6B410T, cb6B410N, cb6B411,
			cb6B411M, cb6B411T, cb6B411N, cb6B412, cb6B412M, cb6B412T,
			cb6B412N, cb6B413, cb6B413M, cb6B413T, cb6B413N, cb6B414, cb6B414M,
			cb6B414T, cb6B414N;
	public TableLayout tl6B;
	public TableRow tr6B11, tr6B12, tr6B13;
	public Spinner sp6B11, sp6B12, sp6B13;
	public EditText et6B11, et6B12, et6B13;
	public EditText et6B1respuesta, et6B2respuesta;
	public RadioButton rb6B3si, rb6B3no;
	public Spinner sp6B5respuesta;

	public CapituloVIDao cap6dao;
	public int Nro_Ed;
	public int Nro_Pred;
	public int P6_2_1;
	public int P6_2_2;
	public String id_local;
	public String edificacion;
	public P6_2 obj2;
	public List<P6_2_4N> lObj2_4;
	public P6_1 obj;
	public List<P6_1_8N> lObj8;
	public List<P6_1_10N> lObj10;
	public int cuestionario;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.capitulo_vi_seccion_b_ambiente);

		IniciarComponentes();

		rb6B3si.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton cb, boolean check) {
				// TODO Auto-generated method stub
				if (check) {
					//tl6B.removeView(tr6B4);
					//tl6B.addView(tr6B4, tl6B.indexOfChild(tr6B3) + 1);
					tr6B4.setVisibility(View.VISIBLE);
				} else {
					cb6B41.setChecked(false);
					cb6B41M.setChecked(false);
					cb6B41T.setChecked(false);
					cb6B41N.setChecked(false);
					cb6B42.setChecked(false);
					cb6B42M.setChecked(false);
					cb6B42T.setChecked(false);
					cb6B42N.setChecked(false);
					cb6B43.setChecked(false);
					cb6B43M.setChecked(false);
					cb6B43T.setChecked(false);
					cb6B43N.setChecked(false);
					cb6B44.setChecked(false);
					cb6B44M.setChecked(false);
					cb6B44T.setChecked(false);
					cb6B44N.setChecked(false);
					cb6B45.setChecked(false);
					cb6B45M.setChecked(false);
					cb6B45T.setChecked(false);
					cb6B45N.setChecked(false);
					cb6B46.setChecked(false);
					cb6B46M.setChecked(false);
					cb6B46T.setChecked(false);
					cb6B46N.setChecked(false);
					cb6B47.setChecked(false);
					cb6B47M.setChecked(false);
					cb6B47T.setChecked(false);
					cb6B47N.setChecked(false);
					cb6B48.setChecked(false);
					cb6B48M.setChecked(false);
					cb6B48T.setChecked(false);
					cb6B48N.setChecked(false);
					cb6B49.setChecked(false);
					cb6B49M.setChecked(false);
					cb6B49T.setChecked(false);
					cb6B49N.setChecked(false);
					cb6B410.setChecked(false);
					cb6B410M.setChecked(false);
					cb6B410T.setChecked(false);
					cb6B410N.setChecked(false);
					cb6B411.setChecked(false);
					cb6B411M.setChecked(false);
					cb6B411T.setChecked(false);
					cb6B411N.setChecked(false);
					cb6B412.setChecked(false);
					cb6B412M.setChecked(false);
					cb6B412T.setChecked(false);
					cb6B412N.setChecked(false);
					cb6B413.setChecked(false);
					cb6B413M.setChecked(false);
					cb6B413T.setChecked(false);
					cb6B413N.setChecked(false);
					cb6B414.setChecked(false);
					cb6B414M.setChecked(false);
					cb6B414T.setChecked(false);
					cb6B414N.setChecked(false);
					//tl6B.removeView(tr6B4);
					tr6B4.setVisibility(View.GONE);
				}
			}
		});

		sp6B5respuesta.setOnItemSelectedListener(new OnItemSelectedListener() {

			@Override
			public void onItemSelected(AdapterView<?> adapter, View v, int pos,
					long arg3) {
				// TODO Auto-generated method stub
				cuestionario = pos;
				switch (pos) {
				case 0:
					tl6B.removeView(tr6B11);
					tl6B.removeView(tr6B12);
					tl6B.removeView(tr6B13);
					break;
				case 1:
					tl6B.removeView(tr6B11);
					tl6B.removeView(tr6B12);
					tl6B.removeView(tr6B13);
					break;
				case 2:
					tl6B.removeView(tr6B11);
					tl6B.removeView(tr6B12);
					tl6B.removeView(tr6B13);
					break;
				case 3:
					tl6B.removeView(tr6B11);
					tl6B.removeView(tr6B12);
					tl6B.removeView(tr6B13);
					tl6B.addView(tr6B11, tl6B.getChildCount());
					sp6B12.setSelection(0);
					sp6B13.setSelection(0);
					et6B12.setText("");
					et6B13.setText("");
					if (obj2 != null) {
						if (obj2.getP6_2_11() != 0) {
							sp6B11.setSelection(obj2.getP6_2_11());
							if (obj2.getP6_2_11_O().length() != 0) {
								et6B11.setEnabled(true);
								et6B11.setText(obj2.getP6_2_11_O());
							}
						}
					} else {
						sp6B11.setSelection(0);
					}
					break;
				case 4:
					tl6B.removeView(tr6B11);
					tl6B.removeView(tr6B12);
					tl6B.removeView(tr6B13);
					tl6B.addView(tr6B12, tl6B.getChildCount());
					sp6B11.setSelection(0);
					sp6B13.setSelection(0);
					et6B11.setText("");
					et6B13.setText("");
					if (obj2 != null) {
						if (obj2.getP6_2_12() != 0) {
							sp6B12.setSelection(obj2.getP6_2_12());
							if (obj2.getP6_2_12_O().length() != 0) {
								et6B12.setEnabled(true);
								et6B12.setText(obj2.getP6_2_12_O());
							}
						}
					} else {
						sp6B12.setSelection(0);
					}
					break;
				case 5:
					tl6B.removeView(tr6B11);
					tl6B.removeView(tr6B12);
					tl6B.removeView(tr6B13);
					tl6B.addView(tr6B13, tl6B.getChildCount());
					sp6B11.setSelection(0);
					sp6B12.setSelection(0);
					et6B11.setText("");
					et6B12.setText("");
					if (obj2 != null) {
						if (obj2.getP6_2_13() != 0) {
							sp6B13.setSelection(obj2.getP6_2_13());
							if (obj2.getP6_2_13_O().length() != 0) {
								et6B13.setEnabled(true);
								et6B13.setText(obj2.getP6_2_13_O());
							}
						}
					} else {
						sp6B13.setSelection(0);
					}
					break;

				default:
					break;
				}
			}

			@Override
			public void onNothingSelected(AdapterView<?> arg0) {
				// TODO Auto-generated method stub

			}
		});

		sp6B11.setOnItemSelectedListener(new OnItemSelectedListener() {

			@Override
			public void onItemSelected(AdapterView<?> adapter, View v, int pos,
					long arg3) {
				// TODO Auto-generated method stub
				switch (pos) {
				case 0:
					et6B11.setText("");
					et6B11.setEnabled(false);
					et6B11.setVisibility(View.INVISIBLE);
					cuestionario = 0;
					break;

				case 11:
					et6B11.setEnabled(true);
					et6B11.setVisibility(View.VISIBLE);
					cuestionario = 1;
					break;

				default:
					et6B11.setText("");
					et6B11.setEnabled(false);
					et6B11.setVisibility(View.INVISIBLE);
					cuestionario = 1;
					break;
				}
			}

			@Override
			public void onNothingSelected(AdapterView<?> arg0) {
				// TODO Auto-generated method stub

			}
		});

		sp6B12.setOnItemSelectedListener(new OnItemSelectedListener() {

			@Override
			public void onItemSelected(AdapterView<?> adapter, View v, int pos,
					long arg3) {
				// TODO Auto-generated method stub
				switch (pos) {
				case 0:
					et6B12.setText("");
					et6B12.setEnabled(false);
					et6B12.setVisibility(View.INVISIBLE);
					cuestionario = 0;
					break;

				case 7:
					et6B12.setEnabled(true);
					et6B12.setVisibility(View.VISIBLE);
					cuestionario = 1;
					break;

				case 8:
					et6B12.setText("");
					et6B12.setEnabled(false);
					et6B12.setVisibility(View.INVISIBLE);
					cuestionario = 3;
					break;
				default:
					et6B12.setText("");
					et6B12.setEnabled(false);
					et6B12.setVisibility(View.INVISIBLE);
					cuestionario = 1;
					break;
				}
			}

			@Override
			public void onNothingSelected(AdapterView<?> arg0) {
				// TODO Auto-generated method stub

			}
		});

		sp6B13.setOnItemSelectedListener(new OnItemSelectedListener() {

			@Override
			public void onItemSelected(AdapterView<?> adapter, View v, int pos,
					long arg3) {
				// TODO Auto-generated method stub
				switch (pos) {
				case 0:
					et6B13.setText("");
					et6B13.setEnabled(false);
					et6B13.setVisibility(View.INVISIBLE);
					cuestionario = 0;
					break;

				case 1:
					et6B13.setText("");
					et6B13.setEnabled(false);
					et6B13.setVisibility(View.INVISIBLE);
					cuestionario = 3;
					break;

				case 2:
					et6B13.setText("");
					et6B13.setEnabled(false);
					et6B13.setVisibility(View.INVISIBLE);
					cuestionario = 3;
					break;

				case 16:
					et6B13.setEnabled(true);
					et6B13.setVisibility(View.VISIBLE);
					cuestionario = 1;
					break;

				default:
					et6B13.setText("");
					et6B13.setEnabled(false);
					et6B13.setVisibility(View.INVISIBLE);
					cuestionario = 1;
					break;
				}
			}

			@Override
			public void onNothingSelected(AdapterView<?> arg0) {
				// TODO Auto-generated method stub

			}
		});

		cb6B41.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton cb, boolean check) {
				// TODO Auto-generated method stub
				if (check) {
					if (rb6B3si.isChecked()) {
						cb6B41M.setEnabled(true);
						cb6B41T.setEnabled(true);
						cb6B41N.setEnabled(true);
					}
				} else {
					cb6B41M.setChecked(false);
					cb6B41T.setChecked(false);
					cb6B41N.setChecked(false);
					cb6B41M.setEnabled(false);
					cb6B41T.setEnabled(false);
					cb6B41N.setEnabled(false);
				}
			}
		});

		cb6B42.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton cb, boolean check) {
				// TODO Auto-generated method stub
				if (check) {
					cb6B42M.setEnabled(true);
					cb6B42T.setEnabled(true);
					cb6B42N.setEnabled(true);
				} else {
					cb6B42M.setChecked(false);
					cb6B42T.setChecked(false);
					cb6B42N.setChecked(false);
					cb6B42M.setEnabled(false);
					cb6B42T.setEnabled(false);
					cb6B42N.setEnabled(false);
				}
			}
		});

		cb6B43.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton cb, boolean check) {
				// TODO Auto-generated method stub
				if (check) {
					cb6B43M.setEnabled(true);
					cb6B43T.setEnabled(true);
					cb6B43N.setEnabled(true);
				} else {
					cb6B43M.setChecked(false);
					cb6B43T.setChecked(false);
					cb6B43N.setChecked(false);
					cb6B43M.setEnabled(false);
					cb6B43T.setEnabled(false);
					cb6B43N.setEnabled(false);
				}
			}
		});

		cb6B44.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton cb, boolean check) {
				// TODO Auto-generated method stub
				if (check) {
					cb6B44M.setEnabled(true);
					cb6B44T.setEnabled(true);
					cb6B44N.setEnabled(true);
				} else {
					cb6B44M.setChecked(false);
					cb6B44T.setChecked(false);
					cb6B44N.setChecked(false);
					cb6B44M.setEnabled(false);
					cb6B44T.setEnabled(false);
					cb6B44N.setEnabled(false);
				}
			}
		});

		cb6B45.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton cb, boolean check) {
				// TODO Auto-generated method stub
				if (check) {
					cb6B45M.setEnabled(true);
					cb6B45T.setEnabled(true);
					cb6B45N.setEnabled(true);
				} else {
					cb6B45M.setChecked(false);
					cb6B45T.setChecked(false);
					cb6B45N.setChecked(false);
					cb6B45M.setEnabled(false);
					cb6B45T.setEnabled(false);
					cb6B45N.setEnabled(false);
				}
			}
		});

		cb6B46.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton cb, boolean check) {
				// TODO Auto-generated method stub
				if (check) {
					cb6B46M.setEnabled(true);
					cb6B46T.setEnabled(true);
					cb6B46N.setEnabled(true);
				} else {
					cb6B46M.setChecked(false);
					cb6B46T.setChecked(false);
					cb6B46N.setChecked(false);
					cb6B46M.setEnabled(false);
					cb6B46T.setEnabled(false);
					cb6B46N.setEnabled(false);
				}
			}
		});

		cb6B47.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton cb, boolean check) {
				// TODO Auto-generated method stub
				if (check) {
					cb6B47M.setEnabled(true);
					cb6B47T.setEnabled(true);
					cb6B47N.setEnabled(true);
				} else {
					cb6B47M.setChecked(false);
					cb6B47T.setChecked(false);
					cb6B47N.setChecked(false);
					cb6B47M.setEnabled(false);
					cb6B47T.setEnabled(false);
					cb6B47N.setEnabled(false);
				}
			}
		});

		cb6B48.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton cb, boolean check) {
				// TODO Auto-generated method stub
				if (check) {
					cb6B48M.setEnabled(true);
					cb6B48T.setEnabled(true);
					cb6B48N.setEnabled(true);
				} else {
					cb6B48M.setChecked(false);
					cb6B48T.setChecked(false);
					cb6B48N.setChecked(false);
					cb6B48M.setEnabled(false);
					cb6B48T.setEnabled(false);
					cb6B48N.setEnabled(false);
				}
			}
		});

		cb6B49.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton cb, boolean check) {
				// TODO Auto-generated method stub
				if (check) {
					cb6B49M.setEnabled(true);
					cb6B49T.setEnabled(true);
					cb6B49N.setEnabled(true);
				} else {
					cb6B49M.setChecked(false);
					cb6B49T.setChecked(false);
					cb6B49N.setChecked(false);
					cb6B49M.setEnabled(false);
					cb6B49T.setEnabled(false);
					cb6B49N.setEnabled(false);
				}
			}
		});

		cb6B410.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton cb, boolean check) {
				// TODO Auto-generated method stub
				if (check) {
					cb6B410M.setEnabled(true);
					cb6B410T.setEnabled(true);
					cb6B410N.setEnabled(true);
				} else {
					cb6B410M.setChecked(false);
					cb6B410T.setChecked(false);
					cb6B410N.setChecked(false);
					cb6B410M.setEnabled(false);
					cb6B410T.setEnabled(false);
					cb6B410N.setEnabled(false);
				}
			}
		});

		cb6B411.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton cb, boolean check) {
				// TODO Auto-generated method stub
				if (check) {
					cb6B411M.setEnabled(true);
					cb6B411T.setEnabled(true);
					cb6B411N.setEnabled(true);
				} else {
					cb6B411M.setChecked(false);
					cb6B411T.setChecked(false);
					cb6B411N.setChecked(false);
					cb6B411M.setEnabled(false);
					cb6B411T.setEnabled(false);
					cb6B411N.setEnabled(false);
				}
			}
		});

		cb6B412.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton cb, boolean check) {
				// TODO Auto-generated method stub
				if (check) {
					cb6B412M.setEnabled(true);
					cb6B412T.setEnabled(true);
					cb6B412N.setEnabled(true);
				} else {
					cb6B412M.setChecked(false);
					cb6B412T.setChecked(false);
					cb6B412N.setChecked(false);
					cb6B412M.setEnabled(false);
					cb6B412T.setEnabled(false);
					cb6B412N.setEnabled(false);
				}
			}
		});

		cb6B413.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton cb, boolean check) {
				// TODO Auto-generated method stub
				if (check) {
					cb6B413M.setEnabled(true);
					cb6B413T.setEnabled(true);
					cb6B413N.setEnabled(true);
				} else {
					cb6B413M.setChecked(false);
					cb6B413T.setChecked(false);
					cb6B413N.setChecked(false);
					cb6B413M.setEnabled(false);
					cb6B413T.setEnabled(false);
					cb6B413N.setEnabled(false);
				}
			}
		});

		cb6B414.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(CompoundButton cb, boolean check) {
				// TODO Auto-generated method stub
				if (check) {
					cb6B414M.setEnabled(true);
					cb6B414T.setEnabled(true);
					cb6B414N.setEnabled(true);
				} else {
					cb6B414M.setChecked(false);
					cb6B414T.setChecked(false);
					cb6B414N.setChecked(false);
					cb6B414M.setEnabled(false);
					cb6B414T.setEnabled(false);
					cb6B414N.setEnabled(false);
				}
			}
		});
	}

	private void IniciarComponentes() {
		// TODO Auto-generated method stub
		tlModalidades = (TableLayout) findViewById(R.id.tlModalidades);
		tr6B3 = (TableRow) findViewById(R.id.tr6B3);
		tr6B4 = (TableRow) findViewById(R.id.tr6B4);
		tr6B41 = (TableRow) findViewById(R.id.tr6B41);
		tr6B42 = (TableRow) findViewById(R.id.tr6B42);
		tr6B43 = (TableRow) findViewById(R.id.tr6B43);
		tr6B44 = (TableRow) findViewById(R.id.tr6B44);
		tr6B45 = (TableRow) findViewById(R.id.tr6B45);
		tr6B46 = (TableRow) findViewById(R.id.tr6B46);
		tr6B47 = (TableRow) findViewById(R.id.tr6B47);
		tr6B48 = (TableRow) findViewById(R.id.tr6B48);
		tr6B49 = (TableRow) findViewById(R.id.tr6B49);
		tr6B410 = (TableRow) findViewById(R.id.tr6B410);
		tr6B411 = (TableRow) findViewById(R.id.tr6B411);
		tr6B412 = (TableRow) findViewById(R.id.tr6B412);
		tr6B413 = (TableRow) findViewById(R.id.tr6B413);
		tr6B414 = (TableRow) findViewById(R.id.tr6B414);

		tvEdificacion = (TextView) findViewById(R.id.tvEdificacionNro);

		et6B1respuesta = (EditText) findViewById(R.id.et6B1respuesta);

		et6B2respuesta = (EditText) findViewById(R.id.et6B2respuesta);

		rb6B3si = (RadioButton) findViewById(R.id.rb6B3si);
		rb6B3no = (RadioButton) findViewById(R.id.rb6B3no);

		tl6B = (TableLayout) findViewById(R.id.tl6B);
		tr6B11 = (TableRow) findViewById(R.id.tr6B11);
		tr6B12 = (TableRow) findViewById(R.id.tr6B12);
		tr6B13 = (TableRow) findViewById(R.id.tr6B13);

		cb6B41 = (CheckBox) findViewById(R.id.cb6B41);
		cb6B41M = (CheckBox) findViewById(R.id.cb6B41M);
		cb6B41T = (CheckBox) findViewById(R.id.cb6B41T);
		cb6B41N = (CheckBox) findViewById(R.id.cb6B41N);
		cb6B42 = (CheckBox) findViewById(R.id.cb6B42);
		cb6B42M = (CheckBox) findViewById(R.id.cb6B42M);
		cb6B42T = (CheckBox) findViewById(R.id.cb6B42T);
		cb6B42N = (CheckBox) findViewById(R.id.cb6B42N);
		cb6B43 = (CheckBox) findViewById(R.id.cb6B43);
		cb6B43M = (CheckBox) findViewById(R.id.cb6B43M);
		cb6B43T = (CheckBox) findViewById(R.id.cb6B43T);
		cb6B43N = (CheckBox) findViewById(R.id.cb6B43N);
		cb6B44 = (CheckBox) findViewById(R.id.cb6B44);
		cb6B44M = (CheckBox) findViewById(R.id.cb6B44M);
		cb6B44T = (CheckBox) findViewById(R.id.cb6B44T);
		cb6B44N = (CheckBox) findViewById(R.id.cb6B44N);
		cb6B45 = (CheckBox) findViewById(R.id.cb6B45);
		cb6B45M = (CheckBox) findViewById(R.id.cb6B45M);
		cb6B45T = (CheckBox) findViewById(R.id.cb6B45T);
		cb6B45N = (CheckBox) findViewById(R.id.cb6B45N);
		cb6B46 = (CheckBox) findViewById(R.id.cb6B46);
		cb6B46M = (CheckBox) findViewById(R.id.cb6B46M);
		cb6B46T = (CheckBox) findViewById(R.id.cb6B46T);
		cb6B46N = (CheckBox) findViewById(R.id.cb6B46N);
		cb6B47 = (CheckBox) findViewById(R.id.cb6B47);
		cb6B47M = (CheckBox) findViewById(R.id.cb6B47M);
		cb6B47T = (CheckBox) findViewById(R.id.cb6B47T);
		cb6B47N = (CheckBox) findViewById(R.id.cb6B47N);
		cb6B48 = (CheckBox) findViewById(R.id.cb6B48);
		cb6B48M = (CheckBox) findViewById(R.id.cb6B48M);
		cb6B48T = (CheckBox) findViewById(R.id.cb6B48T);
		cb6B48N = (CheckBox) findViewById(R.id.cb6B48N);
		cb6B49 = (CheckBox) findViewById(R.id.cb6B49);
		cb6B49M = (CheckBox) findViewById(R.id.cb6B49M);
		cb6B49T = (CheckBox) findViewById(R.id.cb6B49T);
		cb6B49N = (CheckBox) findViewById(R.id.cb6B49N);
		cb6B410 = (CheckBox) findViewById(R.id.cb6B410);
		cb6B410M = (CheckBox) findViewById(R.id.cb6B410M);
		cb6B410T = (CheckBox) findViewById(R.id.cb6B410T);
		cb6B410N = (CheckBox) findViewById(R.id.cb6B410N);
		cb6B411 = (CheckBox) findViewById(R.id.cb6B411);
		cb6B411M = (CheckBox) findViewById(R.id.cb6B411M);
		cb6B411T = (CheckBox) findViewById(R.id.cb6B411T);
		cb6B411N = (CheckBox) findViewById(R.id.cb6B411N);
		cb6B412 = (CheckBox) findViewById(R.id.cb6B412);
		cb6B412M = (CheckBox) findViewById(R.id.cb6B412M);
		cb6B412T = (CheckBox) findViewById(R.id.cb6B412T);
		cb6B412N = (CheckBox) findViewById(R.id.cb6B412N);
		cb6B413 = (CheckBox) findViewById(R.id.cb6B413);
		cb6B413M = (CheckBox) findViewById(R.id.cb6B413M);
		cb6B413T = (CheckBox) findViewById(R.id.cb6B413T);
		cb6B413N = (CheckBox) findViewById(R.id.cb6B413N);
		cb6B414 = (CheckBox) findViewById(R.id.cb6B414);
		cb6B414M = (CheckBox) findViewById(R.id.cb6B414M);
		cb6B414T = (CheckBox) findViewById(R.id.cb6B414T);
		cb6B414N = (CheckBox) findViewById(R.id.cb6B414N);

		tvEdificacion = (TextView) findViewById(R.id.tvEdificacionNro);

		sp6B5respuesta = (Spinner) findViewById(R.id.sp6B5respuesta);

		sp6B11 = (Spinner) findViewById(R.id.sp6B11);
		sp6B12 = (Spinner) findViewById(R.id.sp6B12);
		sp6B13 = (Spinner) findViewById(R.id.sp6B13);

		et6B11 = (EditText) findViewById(R.id.et6B11);
		et6B12 = (EditText) findViewById(R.id.et6B12);
		et6B13 = (EditText) findViewById(R.id.et6B13);

		tl6B.removeView(tr6B11);
		tl6B.removeView(tr6B12);
		tl6B.removeView(tr6B13);

		cuestionario = 0;

		CargarDatos();
	}

	private void CargarDatos() {
		// TODO Auto-generated method stub
		id_local = getIntent().getExtras().getString("id_local");
		Nro_Ed = getIntent().getExtras().getInt("Nro_Ed");
		Nro_Pred = getIntent().getExtras().getInt("Nro_Pred");
		P6_2_1 = getIntent().getExtras().getInt("P6_2_1");
		P6_2_2 = getIntent().getExtras().getInt("P6_2_2");

		edificacion = "Local : "
				+ id_local
				+ " - Predio : "
				+ (getIntent().getExtras().getInt("TITULO_PRED") < 10 ? "0"
						: "") + getIntent().getExtras().getInt("TITULO_PRED")
				+ " - Edificaci\u00f3n Nro. " + (Nro_Ed < 10 ? "0" : "")
				+ Nro_Ed;

		tvEdificacion.setText(edificacion);

		cap6dao = new CapituloVIDao(this);
		List<Object> listaDatos = cap6dao.obtenerEdificacionA(id_local, Nro_Ed,
				Nro_Pred);
		obj = (P6_1) listaDatos.get(0);
		lObj8 = (ArrayList<P6_1_8N>) listaDatos.get(1);
		lObj10 = (ArrayList<P6_1_10N>) listaDatos.get(2);

		cap6dao.crearModalidades(lObj10, P6_2_1, P6_2_2);

		List<Object> valores = cap6dao.obtenerAmbiente(id_local, Nro_Ed,
				Nro_Pred, P6_2_1, P6_2_2);
		obj2 = (P6_2) valores.get(0);
		lObj2_4 = (List<P6_2_4N>) valores.get(1);

		String am = P6_2_1 + "";
		et6B1respuesta.setText((am.length() == 1 ? "0" : "") + P6_2_1);
		et6B1respuesta.setEnabled(false);
		et6B1respuesta.setTextColor(Color.BLACK);
		String pi = P6_2_2 + "";
		et6B2respuesta.setText((pi.length() == 1 ? "0" : "") + P6_2_2);
		et6B2respuesta.setEnabled(false);
		et6B2respuesta.setTextColor(Color.BLACK);

		if (obj2.getP6_2_3() != 0) {
			if (obj2.getP6_2_3() == 1) {
				rb6B3si.setChecked(true);
			} else if (obj2.getP6_2_3() == 2) {
				rb6B3no.setChecked(true);
			}
		}

		if (obj2.getP6_2_5() != 0) {
			sp6B5respuesta.setSelection(obj2.getP6_2_5());
		}

		cb6B41.setChecked(lObj2_4.get(0).getP6_2_4MOD() == 1 ? true : false);
		cb6B42.setChecked(lObj2_4.get(1).getP6_2_4MOD() == 1 ? true : false);
		cb6B43.setChecked(lObj2_4.get(2).getP6_2_4MOD() == 1 ? true : false);
		cb6B44.setChecked(lObj2_4.get(3).getP6_2_4MOD() == 1 ? true : false);
		cb6B45.setChecked(lObj2_4.get(4).getP6_2_4MOD() == 1 ? true : false);
		cb6B46.setChecked(lObj2_4.get(5).getP6_2_4MOD() == 1 ? true : false);
		cb6B47.setChecked(lObj2_4.get(6).getP6_2_4MOD() == 1 ? true : false);
		cb6B48.setChecked(lObj2_4.get(7).getP6_2_4MOD() == 1 ? true : false);
		cb6B49.setChecked(lObj2_4.get(8).getP6_2_4MOD() == 1 ? true : false);
		cb6B410.setChecked(lObj2_4.get(9).getP6_2_4MOD() == 1 ? true : false);
		cb6B411.setChecked(lObj2_4.get(10).getP6_2_4MOD() == 1 ? true : false);
		cb6B412.setChecked(lObj2_4.get(11).getP6_2_4MOD() == 1 ? true : false);
		cb6B413.setChecked(lObj2_4.get(12).getP6_2_4MOD() == 1 ? true : false);
		cb6B414.setChecked(lObj2_4.get(13).getP6_2_4MOD() == 1 ? true : false);

		cb6B41M.setChecked(lObj2_4.get(0).getP6_2_4TURNO_M() == 1 ? true
				: false);
		cb6B42M.setChecked(lObj2_4.get(1).getP6_2_4TURNO_M() == 1 ? true
				: false);
		cb6B43M.setChecked(lObj2_4.get(2).getP6_2_4TURNO_M() == 1 ? true
				: false);
		cb6B44M.setChecked(lObj2_4.get(3).getP6_2_4TURNO_M() == 1 ? true
				: false);
		cb6B45M.setChecked(lObj2_4.get(4).getP6_2_4TURNO_M() == 1 ? true
				: false);
		cb6B46M.setChecked(lObj2_4.get(5).getP6_2_4TURNO_M() == 1 ? true
				: false);
		cb6B47M.setChecked(lObj2_4.get(6).getP6_2_4TURNO_M() == 1 ? true
				: false);
		cb6B48M.setChecked(lObj2_4.get(7).getP6_2_4TURNO_M() == 1 ? true
				: false);
		cb6B49M.setChecked(lObj2_4.get(8).getP6_2_4TURNO_M() == 1 ? true
				: false);
		cb6B410M.setChecked(lObj2_4.get(9).getP6_2_4TURNO_M() == 1 ? true
				: false);
		cb6B411M.setChecked(lObj2_4.get(10).getP6_2_4TURNO_M() == 1 ? true
				: false);
		cb6B412M.setChecked(lObj2_4.get(11).getP6_2_4TURNO_M() == 1 ? true
				: false);
		cb6B413M.setChecked(lObj2_4.get(12).getP6_2_4TURNO_M() == 1 ? true
				: false);
		cb6B414M.setChecked(lObj2_4.get(13).getP6_2_4TURNO_M() == 1 ? true
				: false);

		cb6B41T.setChecked(lObj2_4.get(0).getP6_2_4TURNO_T() == 1 ? true
				: false);
		cb6B42T.setChecked(lObj2_4.get(1).getP6_2_4TURNO_T() == 1 ? true
				: false);
		cb6B43T.setChecked(lObj2_4.get(2).getP6_2_4TURNO_T() == 1 ? true
				: false);
		cb6B44T.setChecked(lObj2_4.get(3).getP6_2_4TURNO_T() == 1 ? true
				: false);
		cb6B45T.setChecked(lObj2_4.get(4).getP6_2_4TURNO_T() == 1 ? true
				: false);
		cb6B46T.setChecked(lObj2_4.get(5).getP6_2_4TURNO_T() == 1 ? true
				: false);
		cb6B47T.setChecked(lObj2_4.get(6).getP6_2_4TURNO_T() == 1 ? true
				: false);
		cb6B48T.setChecked(lObj2_4.get(7).getP6_2_4TURNO_T() == 1 ? true
				: false);
		cb6B49T.setChecked(lObj2_4.get(8).getP6_2_4TURNO_T() == 1 ? true
				: false);
		cb6B410T.setChecked(lObj2_4.get(9).getP6_2_4TURNO_T() == 1 ? true
				: false);
		cb6B411T.setChecked(lObj2_4.get(10).getP6_2_4TURNO_T() == 1 ? true
				: false);
		cb6B412T.setChecked(lObj2_4.get(11).getP6_2_4TURNO_T() == 1 ? true
				: false);
		cb6B413T.setChecked(lObj2_4.get(12).getP6_2_4TURNO_T() == 1 ? true
				: false);
		cb6B414T.setChecked(lObj2_4.get(13).getP6_2_4TURNO_T() == 1 ? true
				: false);

		cb6B41N.setChecked(lObj2_4.get(0).getP6_2_4TURNO_N() == 1 ? true
				: false);
		cb6B42N.setChecked(lObj2_4.get(1).getP6_2_4TURNO_N() == 1 ? true
				: false);
		cb6B43N.setChecked(lObj2_4.get(2).getP6_2_4TURNO_N() == 1 ? true
				: false);
		cb6B44N.setChecked(lObj2_4.get(3).getP6_2_4TURNO_N() == 1 ? true
				: false);
		cb6B45N.setChecked(lObj2_4.get(4).getP6_2_4TURNO_N() == 1 ? true
				: false);
		cb6B46N.setChecked(lObj2_4.get(5).getP6_2_4TURNO_N() == 1 ? true
				: false);
		cb6B47N.setChecked(lObj2_4.get(6).getP6_2_4TURNO_N() == 1 ? true
				: false);
		cb6B48N.setChecked(lObj2_4.get(7).getP6_2_4TURNO_N() == 1 ? true
				: false);
		cb6B49N.setChecked(lObj2_4.get(8).getP6_2_4TURNO_N() == 1 ? true
				: false);
		cb6B410N.setChecked(lObj2_4.get(9).getP6_2_4TURNO_N() == 1 ? true
				: false);
		cb6B411N.setChecked(lObj2_4.get(10).getP6_2_4TURNO_N() == 1 ? true
				: false);
		cb6B412N.setChecked(lObj2_4.get(11).getP6_2_4TURNO_N() == 1 ? true
				: false);
		cb6B413N.setChecked(lObj2_4.get(12).getP6_2_4TURNO_N() == 1 ? true
				: false);
		cb6B414N.setChecked(lObj2_4.get(13).getP6_2_4TURNO_N() == 1 ? true
				: false);

		cb6B41M.setEnabled(false);
		cb6B41T.setEnabled(false);
		cb6B41N.setEnabled(false);
		cb6B42M.setEnabled(false);
		cb6B42T.setEnabled(false);
		cb6B42N.setEnabled(false);
		cb6B43M.setEnabled(false);
		cb6B43T.setEnabled(false);
		cb6B43N.setEnabled(false);
		cb6B44M.setEnabled(false);
		cb6B44T.setEnabled(false);
		cb6B44N.setEnabled(false);
		cb6B45M.setEnabled(false);
		cb6B45T.setEnabled(false);
		cb6B45N.setEnabled(false);
		cb6B46M.setEnabled(false);
		cb6B46T.setEnabled(false);
		cb6B46N.setEnabled(false);
		cb6B47M.setEnabled(false);
		cb6B47T.setEnabled(false);
		cb6B47N.setEnabled(false);
		cb6B48M.setEnabled(false);
		cb6B48T.setEnabled(false);
		cb6B48N.setEnabled(false);
		cb6B49M.setEnabled(false);
		cb6B49T.setEnabled(false);
		cb6B49N.setEnabled(false);
		cb6B410M.setEnabled(false);
		cb6B410T.setEnabled(false);
		cb6B410N.setEnabled(false);
		cb6B411M.setEnabled(false);
		cb6B411T.setEnabled(false);
		cb6B411N.setEnabled(false);
		cb6B412M.setEnabled(false);
		cb6B412T.setEnabled(false);
		cb6B412N.setEnabled(false);
		cb6B413M.setEnabled(false);
		cb6B413T.setEnabled(false);
		cb6B413N.setEnabled(false);
		cb6B414M.setEnabled(false);
		cb6B414T.setEnabled(false);
		cb6B414N.setEnabled(false);

		SetearModalidades();

		if (lObj10.get(0).getP6_1_10_e() != 1) {
			tlModalidades.removeView(tr6B41);
		}
		if (lObj10.get(1).getP6_1_10_e() != 1) {
			tlModalidades.removeView(tr6B42);
		}
		if (lObj10.get(2).getP6_1_10_e() != 1) {
			tlModalidades.removeView(tr6B43);
		}
		if (lObj10.get(3).getP6_1_10_e() != 1) {
			tlModalidades.removeView(tr6B44);
		}
		if (lObj10.get(4).getP6_1_10_e() != 1) {
			tlModalidades.removeView(tr6B45);
		}
		if (lObj10.get(5).getP6_1_10_e() != 1) {
			tlModalidades.removeView(tr6B46);
		}
		if (lObj10.get(6).getP6_1_10_e() != 1) {
			tlModalidades.removeView(tr6B47);
		}
		if (lObj10.get(7).getP6_1_10_e() != 1) {
			tlModalidades.removeView(tr6B48);
		}
		if (lObj10.get(8).getP6_1_10_e() != 1) {
			tlModalidades.removeView(tr6B49);
		}
		if (lObj10.get(9).getP6_1_10_e() != 1) {
			tlModalidades.removeView(tr6B410);
		}
		if (lObj10.get(10).getP6_1_10_e() != 1) {
			tlModalidades.removeView(tr6B411);
		}
		if (lObj10.get(11).getP6_1_10_e() != 1) {
			tlModalidades.removeView(tr6B412);
		}
		if (lObj10.get(12).getP6_1_10_e() != 1) {
			tlModalidades.removeView(tr6B413);
		}
		if (lObj10.get(13).getP6_1_10_e() != 1) {
			tlModalidades.removeView(tr6B414);
		}

		if (rb6B3no.isChecked()) {
			tl6B.removeView(tr6B4);
		}
	}

	private void SetearModalidades() {
		// TODO Auto-generated method stub

		cb6B41.setEnabled(lObj10.get(0).getP6_1_10_e() == 1 ? true : false);
		cb6B42.setEnabled(lObj10.get(1).getP6_1_10_e() == 1 ? true : false);
		cb6B43.setEnabled(lObj10.get(2).getP6_1_10_e() == 1 ? true : false);
		cb6B44.setEnabled(lObj10.get(3).getP6_1_10_e() == 1 ? true : false);
		cb6B45.setEnabled(lObj10.get(4).getP6_1_10_e() == 1 ? true : false);
		cb6B46.setEnabled(lObj10.get(5).getP6_1_10_e() == 1 ? true : false);
		cb6B47.setEnabled(lObj10.get(6).getP6_1_10_e() == 1 ? true : false);
		cb6B48.setEnabled(lObj10.get(7).getP6_1_10_e() == 1 ? true : false);
		cb6B49.setEnabled(lObj10.get(8).getP6_1_10_e() == 1 ? true : false);
		cb6B410.setEnabled(lObj10.get(9).getP6_1_10_e() == 1 ? true : false);
		cb6B411.setEnabled(lObj10.get(10).getP6_1_10_e() == 1 ? true : false);
		cb6B412.setEnabled(lObj10.get(11).getP6_1_10_e() == 1 ? true : false);
		cb6B413.setEnabled(lObj10.get(12).getP6_1_10_e() == 1 ? true : false);
		cb6B414.setEnabled(lObj10.get(13).getP6_1_10_e() == 1 ? true : false);

		if (cb6B41.isChecked()) {
			cb6B41M.setEnabled(true);
			cb6B41T.setEnabled(true);
			cb6B41N.setEnabled(true);
		}
		if (cb6B42.isChecked()) {
			cb6B42M.setEnabled(true);
			cb6B42T.setEnabled(true);
			cb6B42N.setEnabled(true);
		}
		if (cb6B43.isChecked()) {
			cb6B43M.setEnabled(true);
			cb6B43T.setEnabled(true);
			cb6B43N.setEnabled(true);
		}
		if (cb6B44.isChecked()) {
			cb6B44M.setEnabled(true);
			cb6B44T.setEnabled(true);
			cb6B44N.setEnabled(true);
		}
		if (cb6B45.isChecked()) {
			cb6B45M.setEnabled(true);
			cb6B45T.setEnabled(true);
			cb6B45N.setEnabled(true);
		}
		if (cb6B46.isChecked()) {
			cb6B46M.setEnabled(true);
			cb6B46T.setEnabled(true);
			cb6B46N.setEnabled(true);
		}
		if (cb6B47.isChecked()) {
			cb6B47M.setEnabled(true);
			cb6B47T.setEnabled(true);
			cb6B47N.setEnabled(true);
		}
		if (cb6B48.isChecked()) {
			cb6B48M.setEnabled(true);
			cb6B48T.setEnabled(true);
			cb6B48N.setEnabled(true);
		}
		if (cb6B49.isChecked()) {
			cb6B49M.setEnabled(true);
			cb6B49T.setEnabled(true);
			cb6B49N.setEnabled(true);
		}
		if (cb6B410.isChecked()) {
			cb6B410M.setEnabled(true);
			cb6B410T.setEnabled(true);
			cb6B410N.setEnabled(true);
		}
		if (cb6B411.isChecked()) {
			cb6B411M.setEnabled(true);
			cb6B411T.setEnabled(true);
			cb6B411N.setEnabled(true);
		}
		if (cb6B412.isChecked()) {
			cb6B412M.setEnabled(true);
			cb6B412T.setEnabled(true);
			cb6B412N.setEnabled(true);
		}
		if (cb6B413.isChecked()) {
			cb6B413M.setEnabled(true);
			cb6B413T.setEnabled(true);
			cb6B413N.setEnabled(true);
		}
		if (cb6B414.isChecked()) {
			cb6B414M.setEnabled(true);
			cb6B414T.setEnabled(true);
			cb6B414N.setEnabled(true);
		}

		if (rb6B3no.isChecked()) {
			cb6B41M.setEnabled(false);
			cb6B41T.setEnabled(false);
			cb6B41N.setEnabled(false);
			cb6B42M.setEnabled(false);
			cb6B42T.setEnabled(false);
			cb6B42N.setEnabled(false);
			cb6B43M.setEnabled(false);
			cb6B43T.setEnabled(false);
			cb6B43N.setEnabled(false);
			cb6B44M.setEnabled(false);
			cb6B44T.setEnabled(false);
			cb6B44N.setEnabled(false);
			cb6B45M.setEnabled(false);
			cb6B45T.setEnabled(false);
			cb6B45N.setEnabled(false);
			cb6B46M.setEnabled(false);
			cb6B46T.setEnabled(false);
			cb6B46N.setEnabled(false);
			cb6B47M.setEnabled(false);
			cb6B47T.setEnabled(false);
			cb6B47N.setEnabled(false);
			cb6B48M.setEnabled(false);
			cb6B48T.setEnabled(false);
			cb6B48N.setEnabled(false);
			cb6B49M.setEnabled(false);
			cb6B49T.setEnabled(false);
			cb6B49N.setEnabled(false);
			cb6B410M.setEnabled(false);
			cb6B410T.setEnabled(false);
			cb6B410N.setEnabled(false);
			cb6B411M.setEnabled(false);
			cb6B411T.setEnabled(false);
			cb6B411N.setEnabled(false);
			cb6B412M.setEnabled(false);
			cb6B412T.setEnabled(false);
			cb6B412N.setEnabled(false);
			cb6B413M.setEnabled(false);
			cb6B413T.setEnabled(false);
			cb6B413N.setEnabled(false);
			cb6B414M.setEnabled(false);
			cb6B414T.setEnabled(false);
			cb6B414N.setEnabled(false);
		}
	}

	public void Guardar() {
		obj2.setId_local(id_local);
		obj2.setNro_Ed(Nro_Ed);
		obj2.setNro_Pred(Nro_Pred);
		obj2.setP6_2_1(Integer.parseInt(et6B1respuesta.getText().toString()));
		obj2.setP6_2_2(Integer.parseInt(et6B2respuesta.getText().toString()));
		obj2.setP6_2_3((rb6B3si.isChecked() ? 1 : 2));
		obj2.setP6_2_5(sp6B5respuesta.getSelectedItemPosition());
		obj2.setP6_2_11(sp6B11.getSelectedItemPosition());
		obj2.setP6_2_11_O(et6B11.getText().toString());
		obj2.setP6_2_12(sp6B12.getSelectedItemPosition());
		obj2.setP6_2_12_O(et6B12.getText().toString());
		obj2.setP6_2_13(sp6B13.getSelectedItemPosition());
		obj2.setP6_2_13_O(et6B13.getText().toString());

		for (int i = 0; i < 14; i++) {
			lObj2_4.get(i).setId_local(id_local);
			lObj2_4.get(i).setNro_Ed(Nro_Ed);
			lObj2_4.get(i).setNro_Pred(Nro_Pred);
			lObj2_4.get(i).setP6_2_1(P6_2_1);
			lObj2_4.get(i).setP6_2_2(P6_2_2);
		}

		lObj2_4.get(0).setP6_2_4MOD(cb6B41.isChecked() ? 1 : 0);
		lObj2_4.get(1).setP6_2_4MOD(cb6B42.isChecked() ? 1 : 0);
		lObj2_4.get(2).setP6_2_4MOD(cb6B43.isChecked() ? 1 : 0);
		lObj2_4.get(3).setP6_2_4MOD(cb6B44.isChecked() ? 1 : 0);
		lObj2_4.get(4).setP6_2_4MOD(cb6B45.isChecked() ? 1 : 0);
		lObj2_4.get(5).setP6_2_4MOD(cb6B46.isChecked() ? 1 : 0);
		lObj2_4.get(6).setP6_2_4MOD(cb6B47.isChecked() ? 1 : 0);
		lObj2_4.get(7).setP6_2_4MOD(cb6B48.isChecked() ? 1 : 0);
		lObj2_4.get(8).setP6_2_4MOD(cb6B49.isChecked() ? 1 : 0);
		lObj2_4.get(9).setP6_2_4MOD(cb6B410.isChecked() ? 1 : 0);
		lObj2_4.get(10).setP6_2_4MOD(cb6B411.isChecked() ? 1 : 0);
		lObj2_4.get(11).setP6_2_4MOD(cb6B412.isChecked() ? 1 : 0);
		lObj2_4.get(12).setP6_2_4MOD(cb6B413.isChecked() ? 1 : 0);
		lObj2_4.get(13).setP6_2_4MOD(cb6B414.isChecked() ? 1 : 0);

		lObj2_4.get(0).setP6_2_4TURNO_M(cb6B41M.isChecked() ? 1 : 0);
		lObj2_4.get(1).setP6_2_4TURNO_M(cb6B42M.isChecked() ? 1 : 0);
		lObj2_4.get(2).setP6_2_4TURNO_M(cb6B43M.isChecked() ? 1 : 0);
		lObj2_4.get(3).setP6_2_4TURNO_M(cb6B44M.isChecked() ? 1 : 0);
		lObj2_4.get(4).setP6_2_4TURNO_M(cb6B45M.isChecked() ? 1 : 0);
		lObj2_4.get(5).setP6_2_4TURNO_M(cb6B46M.isChecked() ? 1 : 0);
		lObj2_4.get(6).setP6_2_4TURNO_M(cb6B47M.isChecked() ? 1 : 0);
		lObj2_4.get(7).setP6_2_4TURNO_M(cb6B48M.isChecked() ? 1 : 0);
		lObj2_4.get(8).setP6_2_4TURNO_M(cb6B49M.isChecked() ? 1 : 0);
		lObj2_4.get(9).setP6_2_4TURNO_M(cb6B410M.isChecked() ? 1 : 0);
		lObj2_4.get(10).setP6_2_4TURNO_M(cb6B411M.isChecked() ? 1 : 0);
		lObj2_4.get(11).setP6_2_4TURNO_M(cb6B412M.isChecked() ? 1 : 0);
		lObj2_4.get(12).setP6_2_4TURNO_M(cb6B413M.isChecked() ? 1 : 0);
		lObj2_4.get(13).setP6_2_4TURNO_M(cb6B414M.isChecked() ? 1 : 0);

		lObj2_4.get(0).setP6_2_4TURNO_T(cb6B41T.isChecked() ? 1 : 0);
		lObj2_4.get(1).setP6_2_4TURNO_T(cb6B42T.isChecked() ? 1 : 0);
		lObj2_4.get(2).setP6_2_4TURNO_T(cb6B43T.isChecked() ? 1 : 0);
		lObj2_4.get(3).setP6_2_4TURNO_T(cb6B44T.isChecked() ? 1 : 0);
		lObj2_4.get(4).setP6_2_4TURNO_T(cb6B45T.isChecked() ? 1 : 0);
		lObj2_4.get(5).setP6_2_4TURNO_T(cb6B46T.isChecked() ? 1 : 0);
		lObj2_4.get(6).setP6_2_4TURNO_T(cb6B47T.isChecked() ? 1 : 0);
		lObj2_4.get(7).setP6_2_4TURNO_T(cb6B48T.isChecked() ? 1 : 0);
		lObj2_4.get(8).setP6_2_4TURNO_T(cb6B49T.isChecked() ? 1 : 0);
		lObj2_4.get(9).setP6_2_4TURNO_T(cb6B410T.isChecked() ? 1 : 0);
		lObj2_4.get(10).setP6_2_4TURNO_T(cb6B411T.isChecked() ? 1 : 0);
		lObj2_4.get(11).setP6_2_4TURNO_T(cb6B412T.isChecked() ? 1 : 0);
		lObj2_4.get(12).setP6_2_4TURNO_T(cb6B413T.isChecked() ? 1 : 0);
		lObj2_4.get(13).setP6_2_4TURNO_T(cb6B414T.isChecked() ? 1 : 0);

		lObj2_4.get(0).setP6_2_4TURNO_N(cb6B41N.isChecked() ? 1 : 0);
		lObj2_4.get(1).setP6_2_4TURNO_N(cb6B42N.isChecked() ? 1 : 0);
		lObj2_4.get(2).setP6_2_4TURNO_N(cb6B43N.isChecked() ? 1 : 0);
		lObj2_4.get(3).setP6_2_4TURNO_N(cb6B44N.isChecked() ? 1 : 0);
		lObj2_4.get(4).setP6_2_4TURNO_N(cb6B45N.isChecked() ? 1 : 0);
		lObj2_4.get(5).setP6_2_4TURNO_N(cb6B46N.isChecked() ? 1 : 0);
		lObj2_4.get(6).setP6_2_4TURNO_N(cb6B47N.isChecked() ? 1 : 0);
		lObj2_4.get(7).setP6_2_4TURNO_N(cb6B48N.isChecked() ? 1 : 0);
		lObj2_4.get(8).setP6_2_4TURNO_N(cb6B49N.isChecked() ? 1 : 0);
		lObj2_4.get(9).setP6_2_4TURNO_N(cb6B410N.isChecked() ? 1 : 0);
		lObj2_4.get(10).setP6_2_4TURNO_N(cb6B411N.isChecked() ? 1 : 0);
		lObj2_4.get(11).setP6_2_4TURNO_N(cb6B412N.isChecked() ? 1 : 0);
		lObj2_4.get(12).setP6_2_4TURNO_N(cb6B413N.isChecked() ? 1 : 0);
		lObj2_4.get(13).setP6_2_4TURNO_N(cb6B414N.isChecked() ? 1 : 0);

		cap6dao.actualizarSeccionB(obj2, lObj2_4);

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// TODO Auto-generated method stub
		getMenuInflater().inflate(R.menu.menu_capitulovi, menu);
		menu.getItem(0).setTitle("AMBIENTES POR PISO");
		menu.getItem(1).setTitle("SIGUIENTE");
		return super.onCreateOptionsMenu(menu);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub

		switch (item.getItemId()) {
		case R.id.mnSalir:
			AlertDialog.Builder dialogo1 = new AlertDialog.Builder(this);
			dialogo1.setTitle("Importante");
			dialogo1.setMessage("Deseas Salir ?");
			dialogo1.setIcon(android.R.drawable.ic_dialog_alert);
			dialogo1.setCancelable(false);
			dialogo1.setPositiveButton("Si",
					new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialogo1, int id) {
							System.exit(0);
						}
					});

			dialogo1.setNegativeButton("No",
					new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialogo1, int id) {
							return;
						}
					});
			dialogo1.show();
			break;
		case R.id.mnMarco:
			Intent irMarco = new Intent(this, Carga_Trabajo_Activity.class);
			irMarco.putExtras(getIntent().getExtras());
			startActivity(irMarco);
			finish();
			break;
		case R.id.mnIncio:
			Intent marco = new Intent(this,
					CapituloVI_SeccionB_Lista_Ambientes_Activity.class);
			marco.putExtras(getIntent().getExtras());
			startActivity(marco);
			finish();
			break;
		case R.id.mnSiguiente:
			switch (cuestionario) {
			case 0:
				Toast.makeText(this,
						"Debe seleccionar una opci\u00f3n en la pregunta 5.",
						Toast.LENGTH_SHORT).show();
				break;

			case 1:
				Guardar();
				Intent irEstadoConservacion = new Intent(
						CapituloVI_SeccionB_Ambiente_Activity.this,
						CapituloVI_SeccionB_Evaluacion_Del_Estado_De_Conservacion_Activity.class);
				irEstadoConservacion.putExtras(getIntent().getExtras());
				startActivity(irEstadoConservacion);
				finish();
				break;

			case 2:
				Guardar();
				Intent irEspacioPedagogico = new Intent(
						CapituloVI_SeccionB_Ambiente_Activity.this,
						CapituloVI_SeccionB_Espacio_Pedagogico_Activity.class);
				irEspacioPedagogico.putExtras(getIntent().getExtras());
				startActivity(irEspacioPedagogico);
				finish();
				break;

			case 3:
				Guardar();
				Intent irServicios = new Intent(
						CapituloVI_SeccionB_Ambiente_Activity.this,
						CapituloVI_SeccionB_Evaluacion_De_Los_SSHH_Activity.class);
				irServicios.putExtras(getIntent().getExtras());
				startActivity(irServicios);
				finish();
				break;

			default:
				Toast.makeText(this,
						"Debe seleccionar una opci\u00f3n en la pregunta 5.",
						Toast.LENGTH_SHORT).show();
				break;
			}
			break;
		case R.id.mnFoto:
			Intent foto = new Intent(CapituloVI_SeccionB_Ambiente_Activity.this,
					CapituloIX_Activity.class);
			// b.putBoolean("pregunta", true);
			foto.putExtras(getIntent().getExtras());
			foto.putExtra("pregunta", true);
			startActivity(foto);
			break;
		default:
			break;
		}
		return super.onOptionsItemSelected(item);
	}

	@Override
	public void onBackPressed() {
		// TODO Auto-generated method stub
		super.onBackPressed();
		Intent irPredio = new Intent(this,
				CapituloVI_SeccionB_Lista_Ambientes_Activity.class);
		irPredio.putExtras(getIntent().getExtras());
		startActivity(irPredio);
		finish();
	}

}
